package day06;

import java.util.Arrays;

public class ArrayDemo02 {
    public static void main(String[] args) {
/*
       int[] arr0=new int[3];
        int[] arr1={2,3,7};
        int[] arr2=new int[]{2,3,7};
        arr2[0]=100;


        System.out.println(arr0[arr0.length-1]);//0

        Arrays.sort(arr2);//3,7,100




        System.arraycopy(arr2,0,arr0,0,3);//[3,7,100]
        for (int i=0;i<arr0.length;i++){
            System.out.println(arr0[i]);
        }

 */
        /*
        int[] a={10,20,30,40,50};
        int[] b=new int[6];//0,0,0,0,0,0
        //a:源数组
        //0：源数组的起始下标
        //b:目标数组
        //2:目标数组的起始下标
        //3：要复制的元素个数
        System.arraycopy(a,0,b,2,3);//0,0,10,20,30,0
        //0,0,10,20,30,0
        for (int i=0;i<b.length;i++){
            System.out.println(b[i]);
        }

         */




        int[] a={10,20,30,40,50};
        int[] b=Arrays.copyOf(a,6);//[10,20,30,40,50,0]
        //a:源数组
        //b:目标数组
        //4：目标数组的长度
        //若目标数组长度>源数组长度，则末尾补
        for (int i=0;i<b.length;i++){
            System.out.println(b[i]);
        }







    }
}
